package bignumber;

import java.math.BigInteger;

/**
 * @author DCSGO
 * @version 1.0
 * 对于位数很多的整数可用
 * BigInteger
 */
public class BigInteger_ {
    public static void main(String[] args) {
        //对于 BigInteger 的所有操作都得通过方法实现

        //1.创建
        BigInteger bigInteger1 = new BigInteger("123456789012345678901234567890");
        System.out.println(bigInteger1);//           123456789012345678901234567890
        BigInteger bigInteger2 = new BigInteger("987654321098765432109876543210");
        System.out.println(bigInteger2);//           987654321098765432109876543210

        //2.加
        BigInteger add = bigInteger1.add(bigInteger2);
        System.out.println(add);//1111111110111111111011111111100

        //3.减
        BigInteger subtract = bigInteger1.subtract(bigInteger2);
        System.out.println(subtract);//-864197532086419753208641975320

        //4.乘
        BigInteger multiply = bigInteger1.multiply(bigInteger2);
        System.out.println(multiply);//121932631137021795226185032733622923332237463801111263526900

        //5.除
        BigInteger divide = bigInteger1.divide(bigInteger2);
        System.out.println(divide);//0

        divide = bigInteger2.divide(bigInteger1);
        System.out.println(divide);//8
    }
}
